package com.zqr.thread;

/**
 * @author zqr
 * @since 2022/11/4
 */
public class ThreadJoinDemo01 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 5; i++) {
                try {
                    Thread.sleep(1000);
                    System.out.println(Thread.currentThread().getName() + " : " + i);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, "join-thread-01");
        t1.start();
        t1.join();
        for (int i = 0; i < 5; i++) {
            try {
                Thread.sleep(1000);
                System.out.println(Thread.currentThread().getName() + " : " + i);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }


        System.out.println("主线程执行完毕");
    }
}
